home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / lsdchart.lha / lsdchart.s < prev   
Encoding:
Text File  |  1994-06-05  |  4.2 KB  |  231 lines

  1.     Section    Main,Code
  2.  
  3.     ;sourcecode to print out any textfile. Used as VOTER.EXE
  4.     ;on grapevine
  5.  
  6.     ;permission given to use as long as you credit shagratt/LSD
  7.  
  8.     ;by Shagratt/LSD
  9.  
  10.     opt    c+
  11.     
  12.     IncDir    "dh0:Include/"
  13.     include    Intuition/intuition.I
  14.     Include    Intuition/Intuition_Lib.I
  15.     Include    Libraries/dos_LIb.i
  16.     Include    Libraries/Dos.i
  17.     Include    Utility/Reqtools.i
  18.     Include    Utility/Reqtools_lib.i
  19.     Include    Exec/Exec_Lib.I
  20.     Include    Exec/Exec.I
  21.     Include    Misc/EasyStart.i    
  22.  
  23. CALLREQ    Macro
  24.     Move.l    _ReqBase,A6
  25.     Jsr    _LVOrt\1(a6)
  26.     Endm
  27.  
  28. alert_text    MACRO
  29.     dc.w    320-((\1)*4)    ; x co-ords
  30.     dc.b    \2        ; y co-ord
  31. down    SET down+10
  32.     Endm
  33.  
  34.  
  35.     *-----------------------------------------------------------*
  36.     
  37. go:    Lea    DosName,A1        ; Open Dos Library
  38.     Moveq    #0,D0
  39.     CALLEXEC    OpenLibrary
  40.     Move.l     D0,_DOSBase
  41.     Beq    Error
  42.  
  43.     Lea    IntName,A1
  44.     Moveq    #0,D0
  45.     CALLEXEC    OpenLibrary
  46.     Move.l    D0,_IntuitionBase
  47.     Beq    Error
  48.  
  49.     Lea    ReqName,A1        ; Open reqtools library
  50.     Moveq    #0,d0
  51.     CALLEXEC    OpenLibrary
  52.     Move.l    D0,_ReqBase
  53.     Beq    NoReq
  54.     
  55.     Move.l    #RT_REQINFO,D0    ; Prepare requester for use
  56.     Move.l     #0,A0
  57.     CALLREQ    AllocRequestA
  58.     Move.l    D0,ReqInfoStructPtr
  59.  
  60.     *-----------------------------------------------------------*
  61.  
  62.     Lea    AboutText,A1    ;Text for body
  63.     Lea    GadgeText,A2    ;ok gadgets
  64.     Lea    AboutValues,A4    ;value list for %ld
  65.     Move.l    ReqInfoStructPtr,A3
  66.     Lea    AboutTagList,A0
  67.     CALLREQ    EZRequestA        ; display requester
  68.     cmp.l    #0,d0
  69.     beq    Quit
  70.     
  71.     bsr    PrintForm
  72.     beq    Quit
  73.     bsr    Prt_Error
  74.     
  75.     *-----------------------------------------------------------*
  76.  
  77. Quit    Move.l    ReqToolsStructPtr,A1
  78.     CALLREQ    FreeRequest        ; Dealocate Requester 
  79.  
  80. CloseReq    Move.l    _ReqBase,A1
  81.     CALLEXEC    CloseLibrary    ; Close req library
  82.  
  83.     Move.l    _IntuitionBase,A1
  84.     CALLEXEC    CloseLibrary
  85.  
  86.     Move.l    _DOSBase,A1
  87.     CALLEXEC    CloseLibrary
  88.  
  89.     Moveq    #0,d0        ; no return code
  90.     Rts
  91.  
  92.     *-----------------------------------------------------------*
  93.  
  94. PrintForm:    move.l    #printer_filename,d1
  95.     move.l    #MODE_NEWFILE,d2
  96.     CALLDOS    Open        ; open file
  97.     beq    .Prt_Error
  98.     move.l    d0,file_handle
  99.  
  100.     move.l    file_handle,d1
  101.     move.l    #text,d2
  102.     move.l    #textend-text,d3
  103.     CALLDOS    Write
  104.     
  105.     move.l    file_handle,d1
  106.     CALLDOS    Close
  107.  
  108.     clr.l    d0
  109.     rts
  110.  
  111. .Prt_Error
  112.     move.l    #-1,d0
  113.     rts
  114.  
  115.     *-----------------------------------------------------------*
  116.  
  117. NoReq    move.l    #0,d0
  118.     move.l    #alert_string,a0
  119.     move.l    #alert_size,d1
  120.  
  121.     CALLINT    DisplayAlert
  122.  
  123.     bsr    PrintForm
  124.  
  125.     Move.l    _IntuitionBase,A1
  126.     CALLEXEC    CloseLibrary
  127.  
  128.     Move.l    _DOSBase,A1
  129.     CALLEXEC    CloseLibrary
  130.  
  131. Error    Moveq    #0,d0        ; no return code
  132.     Rts
  133.  
  134.     *-----------------------------------------------------------*
  135.  
  136. Prt_Error    Lea    PrtText,A1        ;Text for body
  137.     Lea    OkText,A2        ;ok gadgets
  138.     Lea    AboutValues,A4    ;value list for %ld
  139.     Move.l    ReqInfoStructPtr,A3
  140.     Lea    AboutTagList,A0
  141.     CALLREQ    EZRequestA
  142.  
  143.     rts
  144.  
  145.     *-----------------------------------------------------------*
  146.  
  147. AboutText    dc.b    10
  148.     Dc.b    "LSD HARDNESS CHART",10
  149.     Dc.b    "VOTING FORM PRINTER",10
  150.     Dc.b    " ",10
  151.     Dc.b    "By Shagratt/LSD",10
  152.     dc.b    0
  153.  
  154. PrtText    Dc.b    " ",10
  155.     dc.b    "Failed to open device PRT:",10
  156.     dc.b    0
  157.  
  158.     *-----------------------------------------------------------*
  159.  
  160. GadgeText    Dc.b    "  PRINT  |  CANCEL  ",0
  161. OkText    Dc.b    "  OK  ",0
  162. AboutTitle    Dc.b    "",0
  163.     Even
  164.  
  165.     *-----------------------------------------------------------*
  166.  
  167. AboutValues    dc.l    0
  168.  
  169.     *-----------------------------------------------------------*
  170.  
  171. AboutTagList
  172.     Dc.l    RT_Window
  173.     Dc.l    0
  174.     Dc.l    RT_ReqPos
  175.     Dc.l    REQPOS_CENTERSCR    
  176.     Dc.l    RT_WaitPointer
  177.     Dc.l    -1
  178.     Dc.l    RTEZ_ReqTitle
  179.     Dc.l    AboutTitle
  180.     Dc.l    RTEZ_Flags
  181.     DC.l    EZREQF_CENTERTEXT
  182.     DC.l    TAG_END
  183.  
  184.     *-----------------------------------------------------------*
  185.  
  186. alert_string:
  187.  
  188. down SET    20
  189.  
  190.     alert_text (.a2-.a1),down
  191. .a1    dc.b    "Can't open REQTOOLS.Library - No user interface available",0
  192. .a2    dc.b    1    ; another line
  193.     
  194.     dc.b    0
  195.     even
  196.  
  197. alert_size    = down+5
  198.  
  199.     *-----------------------------------------------------------*
  200.  
  201. ReqToolsStructPtr    Dc.l    0
  202. ReqInfoStructPtr    Dc.l    0
  203.  
  204.     *-----------------------------------------------------------*
  205.  
  206. file_handle        dc.l    0
  207. printer_filename    dc.b    "PRT:",0
  208.  
  209.     *-----------------------------------------------------------*
  210.  
  211. _DOSBase    Dc.l    0
  212. _ReqBase    Dc.l    0
  213. _IntuitionBase    Dc.l    0
  214.  
  215. DosName    DOSNAME
  216. IntName    INTNAME
  217. ReqName    Dc.b    "reqtools.library",0
  218.     Even
  219.     
  220.     *-----------------------------------------------------------*
  221.  
  222. text:    incbin    "textfile.txt"    ;file to print!
  223.     dc.b    12        ; formfeed    
  224. textend:    
  225.  
  226.     
  227.     end
  228.     
  229.  
  230.  
  231.